/** \file gu_stream_map.h */
#pragma once

#include "gu_shader_parser.h"

#include <memory>

namespace gu {

class VertexBuffer;
class IndexBuffer;
class Shader;

/** Abstract class. Implements platform specific mapping for input and output streams. 

    Stream map is a platform specific , singleton like adapter like uniform map.

    TODO: On refactoring:
        GL VertexBuffers are to be handled by VertexBufferMap : StreamMap
        to which most of the functionality in VertexBuffer (to be renamed StreamData) is
        then to be transferred.

        Now Renderer<-attach mesh
            Renderer.render := mesh.vertexbuffer.draw
        Then:
            Before attach: ShaderAdapater <- reflect MaterialSlot
            then
            Renderer <- attach ShaderAdapter
            Renderer.render := ShaderAdapter.draw := <Let StreamMap see if it's current and if so then just glDrawElements as before>

            MaterialSlot: has StreamData, ShaderAdapter: has VertexBufferMap 

            */
class StreamMap
{
public:
    /** Attach vertex buffer. */
    virtual void vertexBuffer(VertexBuffer* buffer) = 0;
    /** Get reference to vertex buffer. */
    virtual VertexBuffer* vertexBuffer() = 0;

    /** Attach index buffer. */
    virtual void indexBuffer(IndexBuffer* buffer) = 0;
    /** Get reference to index buffer. */
    virtual IndexBuffer* indexBuffer() = 0;

    virtual bool render() = 0;

    /** Is attached. */
    virtual bool attached() = 0;
};

typedef std::shared_ptr<StreamMap> StreamMapPtr;


StreamMap* newStreamMap(ShaderDialect dialect);

}
